home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / circuits / irsim-9.000 / irsim-9 / src / include / net.h < prev   
C/C++ Source or Header  |  1993-01-15  |  11KB  |  316 lines

  1. /* 
  2.  *     ********************************************************************* 
  3.  *     * Copyright (C) 1988, 1990 Stanford University.                     * 
  4.  *     * Permission to use, copy, modify, and distribute this              * 
  5.  *     * software and its documentation for any purpose and without        * 
  6.  *     * fee is hereby granted, provided that the above copyright          * 
  7.  *     * notice appear in all copies.  Stanford University                 * 
  8.  *     * makes no representations about the suitability of this            * 
  9.  *     * software for any purpose.  It is provided "as is" without         * 
  10.  *     * express or implied warranty.  Export of this software outside     * 
  11.  *     * of the United States of America may require an export license.    * 
  12.  *     ********************************************************************* 
  13.  */
  14.  
  15.  
  16. /* header for event driven mosfet simulator.  Chris Terman (6/84) */
  17.  
  18. typedef struct Event    *evptr;
  19. typedef struct Node    *nptr;
  20. typedef struct Trans    *tptr;
  21. typedef struct Input    *iptr;
  22. typedef struct Tlist    *lptr;
  23. typedef struct HistEnt    *hptr;
  24. typedef struct Bits     *bptr;
  25. typedef struct thevenin    *Thev;
  26.  
  27.  
  28. typedef unsigned long  Ulong;
  29. typedef unsigned int   Uint;
  30. typedef unsigned char  Uchar;
  31. typedef int (*ifun)();
  32.  
  33.  
  34. struct Tlist
  35.   {
  36.     lptr    next;        /* next list element */
  37.     tptr    xtor;        /* txtor connected to this node */
  38.   };
  39.  
  40.  
  41. struct Event
  42.   {
  43.     evptr    flink, blink;    /* doubly-linked event list */
  44.     evptr    nlink;        /* link for list of events for this node */
  45.     nptr     enode;        /* node this event is all about */
  46.     union
  47.       {
  48.     nptr  cause;        /* node which caused this event to happen */
  49.     hptr  hist;        /* ptr. to history entry that queued this */
  50.     long  oldt;        /* original time for delayed events */
  51.       } p;
  52.     long     ntime;        /* time, in DELTAs, of this event */
  53.     long     delay;        /* delay associated with this event */
  54.     short    rtime;        /* rise/fall time, in DELTAs */
  55.     Uchar    eval;        /* new value */
  56.     Uchar    type;        /* type of event (for incremental only) */
  57.   };
  58.  
  59. typedef struct
  60.   {
  61.     short    delay;              /* delay from input */
  62.     short    rtime;              /* rise/fall time */
  63.   } RegTimes;
  64.  
  65. typedef struct
  66.   {
  67.     Uint    delay : 12;              /* delay from input */
  68.     Uint    rtime : 10;              /* rise/fall time */
  69.     Uint    ptime : 10;              /* punt time */
  70.   } PuntTimes;
  71.  
  72. typedef struct HistEnt
  73.   {
  74.     hptr     next;                  /* next transition in history */
  75.     Ulong    time  : sizeof(Ulong) * 8 - 4;   /* time of transition */
  76.     Uint     inp   : 1;                  /* 1 if node became an input */
  77.     Uint     punt  : 1;                  /* 1 if this event was punted */
  78.     Uint     val   : 2;                  /* value: HIGH, LOW, or X */
  79.     union
  80.       {
  81.     RegTimes    r;
  82.     PuntTimes   p;
  83.       } t;
  84.   } HistEnt;
  85.  
  86.  
  87. #define    MAX_TIME    ( (~((Ulong) 0)) >> 4 )        /* a huge time */
  88.  
  89. extern    Ulong  max_time;        /* contains MAX_TIME (compiler bug) */
  90.  
  91.  
  92. struct Node
  93.   {
  94.     nptr     nlink;    /* sundries list */
  95.     evptr    events;    /* charge sharing event */
  96.     lptr     ngate;    /* list of xtors w/ gates connected to this node */
  97.     lptr     nterm;    /* list of xtors w/ src/drn connected to this node */
  98.     nptr     hnext;    /* link in hash bucket */
  99.     float    ncap;    /* capacitance of node in pf */
  100.     float    vlow;    /* low logic threshold for node, normalized units */
  101.     float    vhigh;    /* high logic threshold for node, normalized units */
  102.     short    tplh;    /* low to high transition time in DELTA's */
  103.     short    tphl;    /* high to low transition time in DELTA's */
  104.     union
  105.       {
  106.     Ulong  time;    /* time, in DELTAs, of last transistion */
  107.     float  cap;    /* incremental capacitance during net-changes */
  108.     evptr  event;    /* non threaded events in incremental simulation */
  109.       } c;
  110.     union
  111.      {
  112.     nptr  cause;    /* node which caused last transition of this node */
  113.     hptr  punts;    /* punted events during incremental simulation */
  114.     tptr  tran;    /* transistor into which stacked xtors were merged */
  115.      } t;
  116.     short    npot;    /* current potential */
  117.     short    oldpot;    /* old potential (for incremental simulation). */
  118.     long     nflags;    /* flag word (see defs below) */
  119.     char     *nname;    /* ascii name of node */
  120.     union
  121.       {
  122.     Thev  thev;    /* used to temporarily store the thevenin structure */
  123.     nptr  next;    /* used to build node lists during net changes */
  124.     tptr  tran;    /* used to mark parallel transistors */
  125.       } n;
  126.     HistEnt  head;    /* first entry in transition history */
  127.     hptr     curr;    /* ptr. to current history entry */
  128. #ifdef FAULT_SIM
  129.     HistEnt  hchange;    /* special entry to avoid changing the history */ 
  130. #endif
  131.   };
  132.  
  133.  
  134. typedef struct        /* same as Res_1 but indexed dynamic resists */
  135.   {
  136.     float  dynres[ 2 ];        /* dynamic resistances [R_LOW - R_MAX] */
  137.     float  rstatic;        /* static resistance of transistor */
  138.     Ulong  width, length;    /* transistor size in centimicrons */
  139.   } Resists;
  140.  
  141. #define    R_LOW        0        /* dynamic low resiatance index */
  142. #define    R_HIGH        1        /* dynamic high resiatance index */
  143.  
  144. #define    dynlow        dynres[ R_LOW ]    /* abbrevations for above */
  145. #define    dynhigh        dynres[ R_HIGH ]
  146.  
  147.  
  148. typedef union
  149.   {
  150.     Thev  r;
  151.     tptr  t;
  152.     int   i;
  153.  } TCache;
  154.  
  155. typedef union
  156.   {
  157.     long  pos;
  158.     tptr  ptr;
  159.   } TPos;
  160.  
  161. struct Trans
  162.   {
  163.     nptr     gate, source, drain;    /* nodes to which trans is connected */
  164.     TCache   scache, dcache;         /* caches to remember src/drn values */
  165.     Uchar    ttype;             /* type of transistor */
  166.     Uchar    state;             /* cache to remember current state */
  167.     Uchar    tflags;              /* transistor flags */
  168.     Uchar    n_par;             /* index into parallel list */
  169.     Resists  *r;             /* transistor resistances */
  170.     tptr     tlink;             /* next txtor in position hash table */
  171.     TPos     x, y;             /* position in the layout (optional) */
  172.   };
  173.  
  174.  
  175. typedef struct Bits
  176.   {
  177.     bptr    next;        /* next bit vector in chain */
  178.     char    *name;        /* name of this vector of bits */
  179.     int     traced;        /* <>0 if this vector is being traced */
  180.     int     nbits;        /* number of bits in this vector */
  181.     nptr    nodes[1];        /* pointers to the bits (nodes) */
  182.   } Bits;
  183.  
  184.  
  185.     /* linked list of inputs */
  186. struct Input
  187.   {
  188.     iptr    next;        /* next element of list */
  189.     nptr    inode;        /* pointer to this input node */
  190.   };
  191.  
  192.  
  193.     /* transistor types (ttype) */
  194. #define    NCHAN        0    /* n-channel enhancement */
  195. #define    PCHAN        1    /* p-channel enhancement */
  196. #define    DEP        2    /* depletion */
  197. #define    RESIST        3    /* simple two-terminal resistor */
  198. #define    TYPERESERVED    4    /* reserved for future transistor types */
  199.  
  200. #define    ALWAYSON    0x02    /* transistors not affected by gate logic */
  201.  
  202. #define    GATELIST    0x08    /* set if gate of xistor is a node list */
  203. #define    STACKED        0x10    /* transistor was stacked into gate list */
  204. #define    ORED        0x20    /* result of or'ing parallel transistors */
  205. #define    ORLIST        0x40    /* part of an or'ed transistor */
  206. #define    TCAP        0x80    /* transistor capacitor (source == drain) */
  207.  
  208. #define    NTTYPES        4    /* number of transistor types defined */
  209.  
  210. #define    BASETYPE( T )        ( (T) & 0x07 )
  211.  
  212.     /* transistor states (state)*/
  213. #define    OFF        0    /* non-conducting */
  214. #define    ON        1    /* conducting */
  215. #define    UNKNOWN        2    /* unknown */
  216. #define    WEAK        3    /* weak */
  217.  
  218.     /* transistor temporary flags (tflags) */
  219. #define    CROSSED        0x01    /* Mark for crossing a transistor */
  220. #define BROKEN        0x02    /* Mark a broken transistor to avoid loop */
  221. #define    PBROKEN        0x04    /* Mark as broken a parallel transistor */
  222. #define    PARALLEL    0x08    /* Mark as being a parallel transistor */
  223. #define    ACTIVE_T    0x10    /* incremental status of transistor */
  224.  
  225.     /* figure what's on the *other* terminal node of a transistor */
  226. #define    other_node( T, N )    ((T)->drain == (N) ? (T)->source : (T)->drain)
  227.  
  228.     /* node potentials */
  229. #define    LOW        0    /* low low */
  230. #define    X        1    /* unknown, intermediate, ... value */
  231. #define    X_X        2
  232. #define    HIGH        3    /* logic high */
  233. #define    N_POTS        4    /* number of potentials [LOW-HIGH] */
  234.  
  235. #define    DECAY        4    /* waiting to decay to X (only in events) */
  236.  
  237.     /* possible values for nflags */
  238. #define    DEVIATED    0x000001    /* node's state differs from hist */
  239. #define    POWER_RAIL    0x000002
  240. #define    ALIAS        0x000004
  241. #define    USERDELAY    0x000008
  242. #define    INPUT        0x000010
  243. #define    WATCHED        0x000020
  244. #define    WATCHVECTOR    0x000040
  245. #define    STOPONCHANGE    0x000080
  246. #define    STOPVECCHANGE    0x000100
  247. #define    VISITED        0x000200
  248.  
  249. #define    MERGED        0x000400    /* node is whithin a txtor stack */
  250. #define    DELETED        0x000800    /* node was deleted */
  251.  
  252. #define    H_INPUT        0x001000    /* node is in high input list */
  253. #define    L_INPUT        0x002000    /* node is in low input list */
  254. #define    U_INPUT        0x003000    /* node is in U input list */
  255. #define    X_INPUT        0x004000    /* node is in X input list */
  256.  
  257. #define    INPUT_MASK        ( H_INPUT | L_INPUT | X_INPUT | U_INPUT )
  258. #define    IsInList( flg )        ( (flg) & INPUT_MASK )
  259. #define    INPUT_NUM( flg )    ( ((flg) & INPUT_MASK) >> 12 )
  260.  
  261. #define    CHANGED        0x008000    /* node is affected by a net change */
  262. #define    STIM        0x010000    /* node is used as stimuli */
  263. #define    ACTIVE_CL    0x020000    /* node is in an active cluster */
  264. #define    WAS_ACTIVE    0x040000    /* set if node was ever active */
  265.  
  266.  
  267.     /* resistance types */
  268. #define    STATIC        0    /* static resistance */
  269. #define    DYNHIGH     1    /* dynamic-high resistance */
  270. #define    DYNLOW      2    /* dynamic-low resistance */
  271. #define    POWER        3    /* resist. for power calculation (unused) */
  272. #define    R_TYPES        3    /* number of resistance contexts */
  273.  
  274.     /* Define TRUE and FALSE values */
  275. #define TRUE  1
  276. #define FALSE 0
  277.  
  278.     /* Possible simulator status */
  279. #define    NORM_SIM        0        /* normal mode */
  280. #define    INCR_SIM        01        /* incremental mode */
  281. #define    OUT_OF_MEM        02        /* out of memory flag */
  282.  
  283.     /* Event Types (for incremental simulation only) */
  284.  
  285. #define    IS_INPUT        0x1        /* event makes node input */
  286. #define    IS_XINPUT        0x2        /* event terminates input */
  287.  
  288. #define    REVAL            0x0        /* result of re-evaluation */
  289. #define    DECAY_EV        0x1        /* node is decaying to X */
  290. #define    PUNTED            0x3        /* previously punted event */
  291.  
  292.     /* events > THREAD are NOT threaded into node structure */
  293. #define    THREAD            0x3
  294.  
  295. #define    PENDING            0x4        /* pending from last run */ 
  296. #define    STIMULI            0x8        /* self-schedulled stimuli */
  297. #define    STIM_INP        ( STIMULI | IS_INPUT )
  298. #define    STIM_XINP        ( STIMULI | IS_XINPUT )
  299.  
  300. #define    CHECK_PNT        0x10        /* next change in history */
  301. #define    INP_EV            ( CHECK_PNT | IS_INPUT )
  302. #define    XINP_EV            ( CHECK_PNT | IS_XINPUT )
  303. #define    DELAY_CHK        0x20        /* delayed CHECK_PNT */
  304. #define    DELAY_EV        0x40        /* last REVAL was delayed */
  305.  
  306. #define    CHNG_MODEL        0x80        /* change evaluation model */
  307.  
  308.  
  309.     /* Conversion macros between various time units */
  310. #define    d2ns( D )        ( (D) * 0.1 )        /* deltas to ns */
  311. #define    d2ps( D )        ( (D) * 100.0 )        /* deltas to ps */
  312. #define    ns2d( N )        ( (N) * 10.0 )        /* ns to deltas */
  313. #define    ps2d( P )        ( (P) * 0.01 )        /* ps to deltas */
  314. #define    ps2ns( P )        ( (P) * 0.001 )        /* ps to ns */
  315.  
  316.